package io.netty.test;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;

/**
 * 背景：
 * netty4.1.97版本的池化buf进行了一些改进，这里我们学习之前的池化buf版本
 * */
public class NettyBuf {

    public static void main(String[] args) {
        System.setProperty("io.netty.allocator.type","pooled");
        ByteBuf buffer = ByteBufAllocator.DEFAULT.buffer(255);

        buffer.release();

        ByteBuf buffer1 = ByteBufAllocator.DEFAULT.buffer(255);
        ByteBuf buffer2 = ByteBufAllocator.DEFAULT.buffer(255);
//        System.out.println(buffer);
//
//        int normalizedCapacity = 7;
//        normalizedCapacity |= normalizedCapacity >>>  1;
//        normalizedCapacity |= normalizedCapacity >>>  2;
//        normalizedCapacity |= normalizedCapacity >>>  4;
//        normalizedCapacity |= normalizedCapacity >>>  8;
//        normalizedCapacity |= normalizedCapacity >>> 16;
//        normalizedCapacity ++;
//        System.out.println(normalizedCapacity);
    }
}
